﻿@{
    ViewBag.Title = "InstanceInClosure";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<h2>Instance In Closure</h2>

<script type="text/javascript">
    function Universe2() {
        // the cached instance
        var instance = this;

        // proceed as normal
        this.start_time = 0;
        this.bang = "Big";

        // rewrite the constructor
        Universe2 = function () {
            return instance;
        };
    }

    window.onload = function () {
        // testing
        var uni = new Universe2();
        var uni2 = new Universe2();
        ZEUS.DEBUG.log("uni === uni2:");
        ZEUS.DEBUG.log(uni === uni2);
        ZEUS.DEBUG.log("uni == uni2: ");
        ZEUS.DEBUG.log(uni == uni2);
    }
</script>
